/*
package start.kafka;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

@Component      //1.主要用于标记配置类，兼备Component的效果。
@Slf4j
public class KafkaScheduleTask {

    int count = 0;

    @Autowired
    private Producer producer;

    //@Value("${spring.kafka.topic-name}")
    private String topic;


    @Scheduled(initialDelay = 10000,fixedDelay = 5000)  //延迟10秒执行，方法前后间隔2s
    public void sendRecord() {
        int batchAdd = 100;
        for(int i = 0; i< batchAdd; i++) {
            producer.send(topic, "消息记录" + i);
        }
        log.info("[{}]条记录插入结束，合计插入[{}]", batchAdd, count);
    }
}*/
